package com.akk.module.avs.service;

import com.akk.module.avs.entity.AvsYbBank;
import com.akk.module.avs.entity.AvsYbBankExample;
import com.akk.module.avs.mapper.AvsYbBankMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AvsYbBankService {

    @Autowired
    private AvsYbBankExample bankExample;

    @Autowired
    private AvsYbBankMapper bankMapper;

    public List<AvsYbBank> queryByParams(Map params){
        bankExample.clear();
        AvsYbBankExample.Criteria criteria = bankExample.createCriteria();
        if (params.containsKey("appId"))
            criteria.andAppIdEqualTo(params.get("appId").toString());
        if (params.containsKey("type"))
            if (params.get("type").toString().equals("bankList")){
                criteria.andBankLinkIsNotNull();
            }else if (params.get("type").toString().equals("queryBankList")){
                criteria.andBankQueryUrlIsNotNull();
            }
        return bankMapper.selectByExample(bankExample);
    }

    public AvsYbBank queryById(Long bankId){
        return bankMapper.selectByPrimaryKey(bankId);
    }

    public void save(AvsYbBank bank){
        bankMapper.insert(bank);
    }

    public void del(Long bankId){
        bankMapper.deleteByPrimaryKey(bankId);
    }

}
